from tools.autoregister.autoregister import redis_oper


# 处理redis中的数据
def dispose_redisdata():
    # 删除之前所有正在运行的标记
    print("***初始化redis数据*** 开始")
    keys = redis_oper.conn.keys("*_runstate")
    if keys:
        for key in keys:
            redis_oper.conn.set(key, "false")
    print("   状态标记 ")

    print("   清除意外断开发送消息标记")
    keys = redis_oper.conn.keys("*_sendmsg_swich")
    if keys:
        for key in keys:
            redis_oper.conn.delete(key)

    keys = redis_oper.conn.keys("*_echo")
    if keys:
        for key in keys:
            redis_oper.conn.set(key, "false")
    print("   初始回显状态 ")

    # 清除OLT 唯一标识符
    print("   OLT唯一标识符")
    keys = redis_oper.conn.keys("*_run_uniqueid")
    print("OLT唯一标识符:", keys)
    if keys:
        for key in keys:
            redis_oper.conn.delete(key)
    print("***初始化redis数据*** 结束")
